package com.weigee.ktv.presenter.adapter.rv

import android.view.LayoutInflater
import android.view.ViewGroup
import com.linde.library.adapter.BaseRvAdapter
import com.linde.library.adapter.SimpleViewHolder
import com.weigee.ktv.R
import kotlinx.android.synthetic.main.adapter_apply_supermarket_order_room.view.*

/**
 * Created by linde on 2017/6/5.
 * LinDe
 */
class ApplySupermarketOrderRoomAdapter : BaseRvAdapter<String>() {
    var selectedItem: Int = 0

    override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): SimpleViewHolder {
        val itemView = LayoutInflater.from(parent?.context).inflate(R.layout.adapter_apply_supermarket_order_room, parent, false)
        return SimpleViewHolder(itemView)
    }

    override fun onBindViewHolder(holder: SimpleViewHolder?, position: Int) {
        super.onBindViewHolder(holder, position)
        holder ?: return
        val v = holder.itemView

        val isSelected = selectedItem == position
        v.tv_room.isSelected = isSelected

        v.setOnClickListener {
            selectedItem = position
            notifyDataSetChanged()
        }
    }

    override fun getItemCount(): Int {
//     todo   return super.getItemCount()
        return 6
    }
}